home *** CD-ROM | disk | FTP | other *** search
- ; This keyboard interrupt routine is adapted from
- ; one posted to the blitz list by Vivid Imagination
- ; Thanks for the original code!
- ;
- ; Simply put this in your code somewhere (preferably
- ; near the top :))
- ;
- ; The interrupt will set the following variables:
- ;
- ; LastKey.b - Contains the value of the last
- ; key event
- ;
- ; LastKeyState.b - Set to one if the last key was
- ; detected pressed down and set
- ; to zero if the last key was up
- ;
- ; KeyState.b() - 128 byte array containing the
- ; status of all 128 keys. If the
- ; key is down the value in the
- ; array will be 1 otherwise 0
- ;
- ; Feel free to use this code in whatever you like!
- ;
- ; -- Marcel Weber
-
-
- ;***************************;
- ; ;
- ; Keyboard interrupt begins ;
- ; ;
- ;***************************;
-
- Dim KeyState.b(127)
- SetInt 3
- MOVEQ #0,d0
- MOVE.b $BFEC01,d0
- NOT.b d0
- ROR.b #1,d0
- BTST #7,d0
- BNE Key_Up
- MOVEQ #1,d1
- BRA Finish_Key
- Key_Up:
- BCLR #7,d0
- MOVEQ #0,d1
- Finish_Key:
- PutReg d0,LastKey.b
- PutReg d1,LastKeyState.b
- GetReg a0,&KeyState(LastKey)
- MOVE.b d1,(a0)
- End SetInt
-
- ;***************************;
- ; ;
- ; End of Keyboard interrupt ;
- ; ;
- ;***************************;
-
-
-
- ; The following code is a sample program used to test
- ; the above keyboard interrupt. It will open a window
- ; and display the most recent key press/release at
- ; the top of the window and below that there will be
- ; a list of all the keys currently held down.
- ;
- ; This program has two other uses as well :)
- ;
- ; 1) If you don't know the number for a particular key
- ; on your keyboard then run this and hold down the
- ; key to see what it is.
- ;
- ; 2) If you have an A1200 then you'll find keyboard
- ; lockout a real pain. With this program you can
- ; hold down various keys to see which ones lockout
- ;
- ; NOTE: Its limited to displaying 8 keys at once without
- ; stuffing up. I couldn't press more than 8 on my
- ; A1200 anyway ;)
-
-
- NoCli
- WBenchToFront_
- FindScreen 0
- Use Screen 0
- Window 0,0,0,270,90,$6,"Press ESC to Quit",0,0
- Format "000"
-
- Repeat
- WLocate 1,1
- Print "Key: ",LastKey," is "
- If LastKeyState = 1 Then NPrint "down" Else NPrint "up "
- NPrint ""
-
- KeysDown = 0
- For a=0 To 127
- If KeyState(a)=1 Then Print a," ": KeysDown+1
- Next a
-
- For a=1 To (8-KeysDown)
- Print " "
- Next a
-
- VWait
- Until KeyState(69)=1
-
-
- Free Window 0
- End
-